<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
	<title>Vue多个组件的动画效果</title>
	<script type="text/javascript" src="./vue.js"></script>
	<style type="text/css">
		.v-enter,.v-leave-to {
			opacity: 0;
		}
		.v-enter-active,.v-leave-active {
			transition: 1s
		}
	</style>
</head>
<body>	
	<div id="app">
		<!-- mode定义先进还是先出 -->
		<transition mode="in-out">
			<child-one v-if="show"></child-one>
			<child-two v-else></child-two>
		</transition>
		<transition>
			<component :is="type"></component>
		</transition>
		<button @click="handleClick">goggle</button>
	</div>
	<script>
		Vue.component('child-one' , {
			template : '<div>child one</div>'
		});
		Vue.component('child-two' , {
			template : '<div>child-two</div>'
		});
		var app = new Vue({
			el : '#app' ,
			data : {
				show : true,
				type : 'child-one'
			},
			methods : {
				handleClick : function() {
					this.show = !this.show;
					this.type = (this.type === 'child-one' ? 'child-two' : 'child-one');
				}
			}
		});
	</script>
</body>
</html>